$(document).ready(function() {

  // Iterate through each news
  news = $('.article-summary').each( function(index) {
  
    // Skip RSS
    if($(this).attr('class').indexOf('rss-box') != -1) {
      return true;
    }

    // Get title    
    title = $($(this).children()[0]).text();

    var newsItem = $($(this).children()[2]);
    var update = function update(msg) {
      if (msg != '') {
        newsItem.html(msg);
      } else {
        newsItem.html("<span class='empty hidden'>No additional data found</span>");
      }
    }

    $.ajax({
      type: "get",
      url: "/ajax/additionaldata",
      data: "keyword="+encodeURI(title),
      success: function(msg) { update(msg) },
    });
    
  })
});


